Add closing of log stream at end of job#1090
Conversation
|
The logs of builds are not closed and stay in memory. As a consequence the timers org.jenkinsci.plugins.workflow.log.DelayBufferedOutputStream$Flush keep on rescheduling themselves for completed jobs. |
jglick
left a comment
There was a problem hiding this comment.
This should be called by WorkflowRun.finish. Do you have some way to reproduce the issue you observed?
|
I have it locally all the time. We have pipeline scripts (workflow-cps-plugin) and we notice that there is a steady increase of timers 'org.jenkinsci.plugins.workflow.log.DelayBufferedOutputStream$Flush' with a link to every build-log (console) that has run since start. We run latest Jenkins and latest plugins. Eventually going OOM and Jenkins restarts. |
|
I can only speculate that something in your environment is causing https://github.com/jenkinsci/workflow-job-plugin/blob/c8d7f497b22f41c3acf8d0ea4b7b2c887be959d6/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java#L672 to not be run; or that this patch was not solving the issue either. |
|
@theunb If you can reproduce the issue, we'd be interested to understand what is happening, but on its own the PR doesn't make sense. It sounds like you might already have heap dumps, and if so, it would be interesting to know the concrete types of |
|
@dwnusbaum, we notice an ever increasing number of Timers. In two weeks time we have '12643769630' (twelve billion) executed timers and run about 5000 jobs per weekday, at max 600 in parallel. I have a script to give an overview of these timers in the queue: The rest of the script is long, but it basically goes reflection style to the $Flush task, and counts them as well as print out the referenced OutputStream and file reference and keeps a histogram of time until execution of the task. The script reports on timer-tasks which have been completed, ie 'callable' and 'runner' are 'null' and 'queue.contains(timertask)' returns 'false' and instances of 'org.jenkinsci.plugins.workflow.log.DelayBufferedOutputStream$Flush' and the sum of both.
I guess the number 'nullNotInQueue' depends on how many 'org.jenkinsci.plugins.workflow.log.DelayBufferedOutputStream$Flush' timer-tasks that have been completed. The sum seems to remain stable. |
Testing done
Submitter checklist